import re
import requests


def download_images(url, headers, output_dir):
    response = requests.get(url, headers=headers)
    data = response.text
    imagelist = re.findall('<img src="(.*?)" width="600".*?>', data)
    y = 0
    for i in imagelist:
        y += 1
        url2 = 'https://xcb.fzu.edu.cn/' + i
        response2 = requests.get(url2)
        imagename = url2[-20:]
        with open(output_dir + f'/{y}.jpeg', 'wb') as f:
            f.write(response2.content)



url = 'https://xcb.fzu.edu.cn/info/1071/4481.htm'
headers = {
    'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36 Edg/117.0.2045.31',
    'cookie': 'JSESSIONID=46DED7706662743DF17EEC846E043D9B'
}
output_dir = "image1/"
download_images(url, headers, output_dir)